package com.edu.base.ums.umsMember.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.edu.base.ums.umsMember.domain.UmsMember;

/**
 * 会员Mapper接口
 * 
 * @author lzs
 * @date 2021-02-21
 */
@Mapper
public interface UmsMemberRyMapper 
{
    /**
     * 查询会员
     * 
     * @param id 会员ID
     * @return 会员
     */
    public UmsMember selectUmsMemberRyById(Long id);

    /**
     * 查询会员列表
     * 
     * @param umsMemberRy 会员
     * @return 会员集合
     */
    public List<UmsMember> selectUmsMemberRyList(UmsMember umsMember);

    /**
     * 新增会员
     * 
     * @param umsMemberRy 会员
     * @return 结果
     */
    public int insertUmsMemberRy(UmsMember umsMember);

    /**
     * 修改会员
     * 
     * @param umsMemberRy 会员
     * @return 结果
     */
    public int updateUmsMemberRy(UmsMember umsMember);

    /**
     * 删除会员
     * 
     * @param id 会员ID
     * @return 结果
     */
    public int deleteUmsMemberRyById(Long id);

    /**
     * 批量删除会员
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteUmsMemberRyByIds(Long[] ids);

    @Select({ "<script>",
		"SELECT T.* FROM ums_member T ",
		"WHERE 1=1",    
		"<if test='phone != null and phone != \"\"'>","AND T.phone = #{phone}", "</if>",
		"<if test='username != null and username != \"\"'>","AND T.username LIKE #{username}", "</if>", 
		" and  T.status = '1'",
		"</script>"})
	public List<UmsMember> selectUmsMemberByPhone(@Param("phone")String phone,@Param("username")String username);

    @Select({ "<script>",
		"SELECT T.* FROM ums_member T ",
		"WHERE 1=1",    
		" and  (T.username=#{username}  or T.phone= #{phone} )", 
		" and  T.status = '1'",
		"</script>"})
	public List<UmsMember> getUmsPhoneOrUserName(@Param("phone")String phone,@Param("username")String username);
}
